cmake_minimum_required(VERSION 3.16)
project(roslaunch)

set(CMAKE_CXX_STANDARD 17)

option(BUILD_UNIT_TESTS "Build the unit tests" ON)

if ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL x86_64)
  set(LIBRARY_SO_PATH depend/libs/x86)
else ()
  set(LIBRARY_SO_PATH depend/libs/arm)
endif ()

message(STATUS "LIBRARY_SO_PATH=${LIBRARY_SO_PATH}")
link_directories(
    ${LIBRARY_SO_PATH}
)

include_directories(include)
include_directories(depend/include/)
include_directories(../utils/include)
link_directories(depend/libs)

aux_source_directory(src SRC_DIR)
aux_source_directory(src/launch LAUNCH_DIR)
aux_source_directory(src/watch_dog WATCH_DOG_DIR)
aux_source_directory(src/utils LAUNCH_UTILS_DIR)
aux_source_directory(../utils/src/utils UTILS_UTILS_DIR)
aux_source_directory(../utils/src/ UTILS_DIR)

add_executable(${PROJECT_NAME} ${SRC_DIR} ${LAUNCH_DIR} ${WATCH_DOG_DIR} ${LAUNCH_UTILS_DIR} ${UTILS_DIR} ${UTILS_UTILS_DIR})
TARGET_LINK_LIBRARIES(${PROJECT_NAME} libXmlRpc.a libtinyxml2.a pthread)

if (BUILD_UNIT_TESTS)
  aux_source_directory(tests TEST_DIR)
  add_executable(${PROJECT_NAME}_unit_test ${TEST_DIR} ${UTILS_UTILS_DIR} ${LAUNCH_UTILS_DIR} ${UTILS_DIR})
  TARGET_LINK_LIBRARIES(${PROJECT_NAME}_unit_test libXmlRpc.a libtinyxml2.a pthread -lgtest)
endif ()
